<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
    <style>
        .layui-table-cell {
            text-align: center;
            height: auto;
        }

        .layui-table img {
            max-width: 300px
        }
    </style>
</head>
<body>
<div class="demoTable">
    姓名：
    <div class="layui-inline">
        <input class="layui-input" name="true_name" id="true_name" autocomplete="off">
    </div>
    手机号：
    <div class="layui-inline">
        <input class="layui-input" name="mobile" id="mobile" autocomplete="off">
    </div>
    <button class="layui-btn" data-type="reload">搜索</button>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-normal" lay-event="getCheckData">完成</button>
    </div>
</script>
</body>
</html>
<script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
<script>
    layui.use(['table','jquery','layer'], function () {
        var table = layui.table
            , layer = layui.layer
            , $ = layui.jquery;

        table.render({
            elem: '#test'
            , toolbar: '#toolbarDemo'
            , url: '{:url("/admin/master.master/collageGoodsList")}'
            , cols: [[
                {type: "radio", width: 50}
                , {field: 'id', title: 'ID', unresize: true, sort: true}
                , {field: 'collage_name', title: '活动名称'}
                , {field: 'collage_start_time', title: '拼团开始时间'}
                , {field: 'collage_end_time', title: '拼团结束时间'}
            ]]
            , page: true
            , id: 'testReload'
        });

        var active = {
            reload: function(){
                var true_name = $('#true_name');
                var mobile = $('#mobile');

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        mobile: mobile.val(),
                        true_name: true_name.val()
                    }
                },'data');
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'getCheckData':
                    var data = checkStatus.data;
                    var user_id = [];
                    data.map(function (v,k) {
                        user_id.push(v.id)
                    })
                    var index = parent.layer.getFrameIndex(window.name)
                    parent.getMasterIds(user_id)
                    parent.layer.close(index);
                    break;
            }
        });
    });
</script>